emerald_animal_aifandomcom-20200215-history
Tutorials
We will be adding new tutorials to this section as we develop Emerald further. Have an Animal Damage UFPS Directly Note: You must have UFPS in order for this to work. This also requires altering 3 lines of the actual Emerald Animal AI script. If you'd like, you can create a backup, or simply reimport Emerald if you'd no longer like to use this. Note: This will only work using UFPS Step 1: Open up your Emerald Animal AI script. Step 2: Find the lines below and comment it out using // (there should be 3): currentAnimal.GetComponent().DamagePlayer(attackDamage); Step 3: After commenting out the lines above, add this below each above line (there should be 3): currentAnimal.GetComponent().Damage(attackDamage); Step 4: Disable the PlayerHealth script on your player, if applicable. Step 5: Test this out by having an animal attack your UFPS player. It should do damage directly to your UFPS health handler script instead of the PlayerHealth script. (Fixed) Setting up the Player Weapon and Health System (Updated parts of tutorial with bold underline) We didn't include a full example of this with Emerald v1.1 because we don't want to have to include Standard Assets within the package. This tends to lead to issues. So, we have a tutorial here of exactly how to do so. This will include an example of using Unity's character controller and one example of a UFPS example. Using UFPS: 1) Select the UFPS parent (This UFPS system should have the melee combat weapon type) 2) Find the PlayerHealth script and apply it to the parent of your UFPS GameObject. This is what allows your player object to receive damage. 3) Create a Text UI and apply it to the Player Health Text part of your PlayerHealth script on your UFPS GameObject. This is what allows your player's health to be visible. 4) Find the FPSCamera GameObject within your UFPS parent and apply the PlayerWeapon script to it. This is what allows your player to do damage. 5) Adjust the variables as needed to match your swing animations using UFPS. The PlayerWeapon script allows you to control things like delay speed, damage, swing speed, attack speed, and more. 6) Check whether or not you want to use a blood effect. If you have blood enabled, you will need to apply a blood effect. 7) Apply the Player tag to your UFPS parent gameobject 8) Everything is setup and should be functioning. Do a quick test run to insure everything is working. Using Unity's Character Controller: 1) Select the FPSController parent gameobject 2) Find the PlayerHealth script and apply it to the parent of your FPSController parent gameobject. This is what allows your player object to receive damage. 3) Create a Text UI and apply it to the Player Health Text part of your PlayerHealth script on your FPSController parent gameobject. This is what allows your player's health to be visible. 4) Find the FirstPersonCharacter (the Camera) GameObject within your FPSController parent gameobject and apply the PlayerWeapon script to it. This is what allows your player to do damage. 5) Adjust the variables as needed to match your swing animations (If you have any. If there are non, everything will still work). The PlayerWeapon script allows you to control things like delay speed, damage, swing speed, attack speed, and more. 6) Check whether or not you want to use a blood effect. If you have blood enabled, you will need to apply a blood effect. 7) Apply the Player tag to your FPSController parent gameobject 8) Everything is setup and should be functioning. Do a quick test run to insure everything is working. Setting up Unity's NavMesh This will discuss how to setup Unity's NavMesh. Creating separate areas for different kinds of animals If you want to create different areas for your animals, such as animals that can go both in water and out, but keep land animals out of that areas, than follow this tutorial. This same thing applies for different kinds of animals and their types, you just need some type of object to mask it. Make sure this object is marked as Static. It can be found in the top right corner of the Inspector of that GameObject. 1) Create new Area and call it lets say Don't walk on Water 2) Set your water object to the area Don't walk on Water '''that you just created 3) Go to your AI's NavMeshAgent, that you don't want walking on/in the water, and '''uncheck Don't walk on Water from the'Area Mask ' 4) Rebake your scene. The AI you don't want walking on the water will have the water area marked as unwalkable and the ones that can walk on/in the water will be able to. AI Example Chart Here we've created a reference chart for developing stats your AI. Feel free to use these charts as reference. You can use the same names and stats or tweak them how you'd like. It's entirely up to you!